/** Evento Hide&Seek **/

package handlers.voicedcommandhandlers;

import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.HideAndSeek;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.olympiad.Olympiad;

/**
 * @author BiggBoss
 */
public class HasCmd implements IVoicedCommandHandler {

	private static final String[] _cmd = { "joinhas", "leavehas" };
	
	@Override
	public String[] getVoicedCommandList() {
		return _cmd;
	}

	@Override
	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params) {
		if(activeChar == null) return false;
		
		if(command.startsWith("joinhas")) {
			if(activeChar.isDead()) return false;
			
			else if(activeChar.inObserverMode()) return false;
			
			else if(activeChar.getKarma() > 0 || activeChar.isCursedWeaponEquipped()) {
				activeChar.sendMessage("Cannot join while chaotic state active!");
				return false;
			}
			
			else if(Olympiad.getInstance().isRegistered(activeChar)) {
				activeChar.sendMessage("Cannot join while in Olympiad");
				return false;
			}
			
			else if(activeChar.isInJail()) {
				activeChar.sendMessage("Cannot join while in Jail");
				return false;
			}
			
			else if(TvTEvent.isPlayerParticipant(activeChar.getObjectId())) {
				activeChar.sendMessage("Cannot join while in TvT");
				return false;
			}
			
			else if(activeChar.isIn7sDungeon()) {
				activeChar.sendMessage("Cannot join while in 7sing dungeon");
				return false;
			}
			
			else if(HideAndSeek.addPlayer(activeChar)) {
				activeChar.sendMessage("Registered for the event!");
				return true;
			}
			else  {
				activeChar.sendMessage("Couldnt Register for H&S!");
				return false;
			}
		}
		else if(command.startsWith("leavehas")) {
			if(HideAndSeek.removePlayer(activeChar)){
				activeChar.sendMessage("You have been unregistered for H&S");
				return true;
			}
			else return false;
		}
		return true;
	}
}
